package cn.stylefeng.guns.utils.word;

import cn.stylefeng.guns.modular.wms.model.result.ResumeResult;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;

/**
 * 简历导出工具类
 */
public class ExportResumeUtil {

    public static String exportWordFile(HttpServletRequest request, ResumeResult resumeResult) throws Exception{
        //        new ExportWordUtil("UTF-8").exportDoc(response, fileName, "resume.ftl", getData(resumeResult));
//        new ExportWordUtil("UTF-8").exportDocFile(fileName, "resume.ftl", getData(resumeResult));
       return new ExportWordUtil("UTF-8").exportDocFile(request,"个人简历.doc", "resume.ftl", getData(resumeResult));
    }

    /**
     * 获取word填充数据
     *
     * @param resumeVo
     * @return
     */
    private static Map<String, Object> getData(ResumeResult resumeVo) {
        Map<String, Object> map = new HashMap<>();
        map.put("name", resumeVo.getName());
        map.put("sex", resumeVo.getSex()==1?"男":"女");
        map.put("birthday", resumeVo.getBirthday());
        map.put("phone", resumeVo.getPhone());
        map.put("email", resumeVo.getEmail());
        map.put("timeToWork",resumeVo.getTimeToWork());
        map.put("workYear",resumeVo.getWorkYear());
        map.put("education", resumeVo.getEducation());
        map.put("avatar", resumeVo.getAvatar());
        map.put("jobStatus", resumeVo.getJobStatus());
//        map.put("address", resumeVo.getAddress());
        map.put("personalSkill",resumeVo.getPersonalSkill());
        map.put("eduExpList", resumeVo.getEduExpList());
        map.put("workExpList", resumeVo.getWorkExpList());
        map.put("proExpList", resumeVo.getProExpList());
        map.put("jobExpectList", resumeVo.getJobExpectList());
        return map;
    }

}
